package com.ruoyi.project.api.factory;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.project.api.RemoteProjectService;
import com.ruoyi.project.api.domain.SysStudent;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 用户服务降级处理
 * 
 * @author ruoyi
 */
@Component
public class RemoteProjectFallbackFactory implements FallbackFactory<RemoteProjectService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteProjectFallbackFactory.class);

    @Override
    public RemoteProjectService create(Throwable throwable)
    {
        log.error("用户服务调用失败:{}", throwable.getMessage());
        return new RemoteProjectService()
        {
            @Override
            public R<List<SysStudent>> queryStudentlist(SysStudent student){
                return R.fail("获取学生信息失败:" + throwable.getMessage());
            }
        };
    }
}
